#ifndef TAC_H_
#define TAC_H_

#include "../base/basic_types.h"

#define	LIB_TAC				"./TAClient.dll"
#define LIB_NULL			-8

#define TA_SUCCESS			1
#define TA_FAIL				0
#define TA_QUEUE_EMPTY		-1
#define	TA_QUEUE_FULL		-2
#define TA_LINKOK			1
#define TA_LINKERROR		0

#ifndef HMODULE
#define HMODULE void *
#endif

typedef struct
{
	char8 *pIP;
	char8 *pPort;
	char8 *pDest;
}Config;

//this is a cpp-wrapper of TAC API
class TAC
{
public:
	TAC();
	virtual ~TAC();
	
public:
	int TAStart();
	int TAPutMsg(char *pcpDest, char *pcpMsg);
	int TAPutMsgExt(char *pcpMsg);
	int TAGetMsg(char *pcpOrg, char *pcpMsg);
	int TAGetMsgExt(char *pcpMsg);
	int TAGetLinkStatus();
	int TAClose();
	
public:
	int32 LoadConfig();
	int32 SetConfig(char8 *pIP, char8 *pPort, char8 *pDest);
	
	Config *GetConfig()	const
	{return m_pConfig;}
	
	int Init();
	
private:
	typedef int (*fpTAStart)();
	typedef int	(*fpTAPutMsg)(char *pcpDest, char *pcpMsg);
	typedef int (*fpTAPutMsgExt)(char *pcpMsg);
	typedef	int (*fpTAGetMsg)(char *pcpOrg, char *pcpMsg);
	typedef int	(*fpTAGetMsgExt)(char *pcpMsg);
	typedef int (*fpTAGetLinkStatus)();
	typedef int (*fpTAClose)();
	
	fpTAStart 			m_fpTAStart;
	fpTAPutMsg			m_fpTAPutMsg;
	fpTAPutMsgExt		m_fpTAPutMsgExt;
	fpTAGetMsg			m_fpTAGetMsg;
	fpTAGetMsgExt		m_fpTAGetMsgExt;
	fpTAGetLinkStatus	m_fpTAGetLinkStatus;
	fpTAClose			m_fpTAClose;
	
private:
	TAC(const TAC& tac){}
	TAC& operator = (TAC& tac){return *this;}
	
private:
	HMODULE m_hTAC;
	Config	*m_pConfig;
};

#endif
